package cn.ekuma.pos.pda;

import cn.ekuma.android.ui.scan.ADVCaptureScanActivity;
import cn.ekuma.epos.datalogic.DataLogicPDA;
import cn.ekuma.pos.android.erp.R;
import cn.ekuma.pos.pda.inventory.CustomerViewActivate;
import cn.ekuma.pos.pda.inventory.ProductEditorActivate;
import cn.ekuma.pos.pda.inventory.ProductViewActivate;
import cn.ekuma.pos.pda.order.OrderViewActivate;
import cn.ekuma.pos.pda.order.ShardOrderViewActivate;
import cn.ekuma.pos.pda.order.local.LocalOrderViewActivate;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
import android.widget.Toast;

public class PDAActivity extends Activity implements OnItemClickListener {
	DataLogicPDA dlPDA;
	boolean isLocal;
	String customProductSearch;
	private GridView toolbarGrid;
	
    /** Called when the activity is first created. */
    
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        initView();
    }

	private void initView() {
		toolbarGrid = (GridView) findViewById(R.id.gridView1);
		toolbarGrid.setGravity(Gravity.CENTER);// 位置居中
		toolbarGrid.setHorizontalSpacing(10);// 水平间隔
		toolbarGrid.setAdapter(MainMenuAdapterFactory.getMenuAdapter(this));// 设置菜单Adapter
		toolbarGrid.setOnItemClickListener(this);
	}

	
	public void onItemClick(AdapterView<?> arg0,View view, int position,long id) {
		switch(position){
		   case 0:
			  showActivity(ShardOrderViewActivate.class);
			  break;
		   case 1:
			   showActivity(LocalOrderViewActivate.class);
			   break;
		   case 2:
			   showActivity(OrderViewActivate.class);
			   break;
		   case 3:
			   showActivity(ProductViewActivate.class);
			   break;
		   case 4:
			   showActivity(CustomerViewActivate.class);
			   break;
		   case 5:
			   showActivity(ADVCaptureScanActivity.class);
			   break;
		   case 6:
			   showActivity(ProductEditorActivate.class);
			   break;   
		  
		}
	}

	private void showActivity(Class activityClass)
	{
		Intent intent = new Intent();
    	intent.setClass(this, activityClass);
    	startActivity(intent);
	}
}